package com.drive.room.common;

public enum ResultEnum {
	
	SUCCESS(0,"success"),
	FAILED(-1,"失败"),
	
	//http错误
	IP_ACCESS_ERROR(101,"ip访问受限制"),
	API_ACCESS_ERROR(102,"接口访问受限制"),
	BAB_REQUEST(400,"请求无效 (Bad request)"),
	HTTP_CONNECT_ERROR(404,"远程服务异常"),
	SYSTEM_ERROR(500,"系统错误"),
	
	//解析
	PARAM_ERROR(1000,"参数不合法"),
	XML_PARSE_ERROR(1001,"xml解析异常"),
    JSON_PARSE_ERROR(1002,"json解析异常"),
	SIGN_ERROR(1003,"签名验证错误"),
	INVALID_TIMESTAMP_EXPIRED(1004,"过期请求"),
	LATEST_VERSION(1005,"已是最新版本"),
	REQUEST_METHOD_NOT_SUPPORTED(1006,"不支持请求方式"),
	CONTENT_TYPE_NOT_SUPPORTED(1007,"不支持媒体类型"),
	REQUEST_EXCEPTION(1008,"请求异常"),
	
	//用户
	USER_LOGIN_EXCEPTION(2006,"登录异常"),
	

	
	//token
	TOKEN_UPDATE_FAILED(2200,"token更新失败"),
	TOKEN_INVALID(2201,"token错误"),
	TOKEN_EXPRIED(2202,"token已过期");
	



	private int code;
	private String msg;
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	private ResultEnum(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	
	public static ResultEnum getEnumByCode(int code) {
        for (ResultEnum bt : values()) {
            if (bt.code == code) {
                return bt;
            }
        }
        return null;
    }
}
